﻿<UserControl x:Class="EQual.MainModule.Employees.Trainings.TrainingsGridView"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Models="clr-namespace:EQual.MainModule" 
    xmlns:WpfApplicationExperimental="clr-namespace:WpfApplicationExperimental;assembly=WpfApplicationExperimental"
    xmlns:loc="clr-namespace:RootLibrary.WPF.Localization;assembly=LocalizeExtension"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit" >
    <UserControl.Resources >

        <ObjectDataProvider x:Key="TrainningStatusType" ObjectType="{x:Type Models:EmployeesProvider}" MethodName="GetTrainingStatus" />

    </UserControl.Resources>
    <Grid>
        <dg:DataGrid  Name="dataGrid1"  
                      CanUserAddRows="True"
                      Background="Transparent" 
                      AutoGenerateColumns="False"
                      ItemsSource="{Binding Path=ItemsCollection}" SelectionChanged="dataGrid1_SelectionChanged" RowEditEnding="dataGrid1_RowEditEnding">

            <dg:DataGrid.Columns >
                <dg:DataGridTextColumn Binding="{Binding TrainigId}" Header="{LocText EQualApplication:ResTexts:TrainingId}" />
                <dg:DataGridTextColumn Binding="{Binding TrainingSubjcet}" Header="{LocText EQualApplication:ResTexts:TrainingSubjcet}"/>
                <dg:DataGridTemplateColumn Header="{LocText EQualApplication:ResTexts:TrainingDate}" >
                    <!-- editing template -->
                    <dg:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <dg:DatePicker
                           SelectedDate="{Binding Path=TrainingDate, Mode=TwoWay}"
                           BorderThickness="0"/>
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellEditingTemplate>
                    <!-- standard template -->
                    <dg:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock>
                            <TextBlock.Text>
                                <Binding Path="TrainingDate"
                                   ConverterCulture="en-GB"
                                   StringFormat="{}{0:d}"/>
                            </TextBlock.Text>
                            </TextBlock>
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellTemplate>
                </dg:DataGridTemplateColumn>
                <dg:DataGridComboBoxColumn SelectedValueBinding="{Binding TrainingStatus}"                                            
                                           Header="{LocText EQualApplication:ResTexts:TrainingStatus}"
                                           ItemsSource="{Binding Source={StaticResource TrainningStatusType}}">
                    <dg:DataGridComboBoxColumn.EditingElementStyle>
                        <Style TargetType="ComboBox">
                            <Setter Property="IsEditable" Value="True" />
                        </Style>
                    </dg:DataGridComboBoxColumn.EditingElementStyle>
                </dg:DataGridComboBoxColumn>


            </dg:DataGrid.Columns>
        </dg:DataGrid>
    </Grid>
</UserControl>
